tools/oxenstored: Use more efficient node trees
authorEdwin Török <edvin.torok@citrix.com>
Fri, 8 Jan 2021 11:57:37 +0000 (11:57 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 22 Jan 2021 18:01:35 +0000 (18:01 +0000)
commit3068dfd6415ae7db06112853581b7cbbcecadc2c
tree33cc18bf88198905e6585f0874daf566b3f1285e
parentfaf02c345ec0b2a5bbd45b4f94ffd59e75a42435
tools/oxenstored: Use more efficient node trees

This changes the output of xenstore-ls to be sorted.  Previously the keys were
listed in the order in which they were inserted in.  docs/misc/xenstore.txt
doesn't specify in what order keys are listed.

Map.update is used to retain semantics with replace_child: only an existing
child is replaced, if it wasn't part of the original map we don't add it.
Similarly exception behaviour is retained for del_childname and related
functions.

Entries are stored in reverse sort order, so that upon Map.fold the
constructed list is sorted in ascending order and there is no need for a
List.rev.

This changes the semantics and is not suitable as is for a backport.  It
reveals bugs in buggy clients that depend on xenstore entry order, however
those clients should be fixed.

Signed-off-by: Edwin Török <edvin.torok@citrix.com>
Acked-by: Christian Lindig <christian.lindig@citrix.com>
tools/ocaml/xenstored/store.ml
tools/ocaml/xenstored/symbol.ml
tools/ocaml/xenstored/symbol.mli